package com.bdqn.zhang.service.impl;

import com.bdqn.zhang.dao.UserMapper;
import com.bdqn.zhang.pojo.User;
import com.bdqn.zhang.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/*@Scope("prototype")*/
@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public Integer count() {
        return userMapper.count();
    }

    @Override
    public Integer addUser(User user) {
        Integer count = 0;
        try {
            count = userMapper.addUser(user);
            throw new RuntimeException("throw new Exception");
        }catch (Exception e){
            //捕获异常，继续抛出
            System.out.println("-----throw new Exception-------");
            e.printStackTrace();
        }finally {
        }
        return count;
    }

    @Override
    public User dologin(User user) {
        return userMapper.dologin(user);
    }
}
